<?php
// teams list page
require_once 'view/adm/teamstats/scores.index.php';
require_once 'model/common/session.php';


class ScoresIndexPage extends PageController {

	var $form;

    function ScoresIndexPage() {
        parent::PageController();

        $this->form =& new FormController();
        $this->form->addChild('apply', new ButtonController(new Delegate($this, 'apply')));
        $this->form->addChild('resetScores', new ButtonController(new Delegate($this, 'resetScores')));
        $this->form->addChild('deleteScores', new ButtonController(new Delegate($this, 'deleteScores')));
        $this->form->setDefaultChild('apply');

        	$this->form->addRule(new Handle('NumericRangeRule', array('teamID',0)));
        	//$this->form->addRule(new Handle('NumericRangeRule', array('category1',0)));
        	$this->form->addRule(new Handle('NumericRangeRule', array('start_day',1,31)));
            $this->form->addRule(new Handle('NumericRangeRule', array('end_day',1,31)));
            $this->form->addRule(new Handle('NumericRangeRule', array('start_year',2000,2999)));
            $this->form->addRule(new Handle('NumericRangeRule', array('end_year',2000,2999)));


        $this->addChild('FilterForm', $this->form);
        $this->setDefaultChild('FilterForm');



        $this->setDefaultView(new Handle('ScoresListView', array('/adm/teamstats/scores.index.html')));

        $this->addView('success', WACT_DEFAULT_VIEW);
        $this->addView('notfound', WACT_DEFAULT_VIEW);
        $this->addView('delete', new Handle('RedirectView', array('/delete')));


    }

    //apply filter
    //save filter response model into session
    function apply(&$source, &$request, &$responseModel) {
    	//print 'Applying filter...';
    	Session::saveResponseModel($responseModel,'filter.scores');
    }

    function resetScores(&$source, &$request, &$responseModel) {
    	//print 'Applying filter...';
    	Score::resetAllStats();
    }

    function deleteScores(&$source, &$request, &$responseModel) {
    	//print 'Applying filter...';
    	Score::deleteAllDisabledStats();
    }
}

?>